home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
081-090
/
amok87
/
rekursionen
/
wirth.mod
< prev
next >
Wrap
Text File
|
1993-11-04
|
3KB
|
104 lines
(*------------------------------------------------------------------------------
:Program. Wirth.mod
:Contents. zeichnet (rekursiv) die WIRTH-Kurven
:Author. Matthias Scherrer
:Address. Baselstrasse 63, CH-4242 Laufen
:Phone. ++(0)61/7613975
:Copyright. PD
:Language. Oberon
:Translator. Oberon V3.00d
:History. V1.0,01-Dec-92 fuer Oberon 2.14d
:History. V1.1,29-Dec-92 angepasst an Oberon V3.00d
------------------------------------------------------------------------------*)
MODULE Wirth;
IMPORT di : Display, io, Mouse;
TYPE WinkArr = ARRAY 2,4 OF INTEGER;
CONST
wt = WinkArr ( 3, 0, 1, 2, 1, 2, 3, 0);
height = 480;
width = 710;
VAR
screen : di.ScreenPtr;
retbo : BOOLEAN;
la,ti : INTEGER;
(*------------------------------------------------------------*)
(* Screen oeffnen *)
(*------------------------------------------------------------*)
PROCEDURE InitGraph;
VAR
BEGIN
NEW(screen);
retbo:=di.OpenScreen(screen,"Wirth-Kurven",0,0,width,height,1,TRUE,TRUE);
END InitGraph;
(*------------------------------------------------------------*)
(* Screen schliessen *)
(*------------------------------------------------------------*)
PROCEDURE Close; (* Screen schliessen und Speicher freigeben *)
BEGIN
di.Close(screen);
(* $IFNOT GarbageCollector *)
DISPOSE(screen);
(* $END *)
END Close;
(*------------------------------------------------------------*)
(* Zeichnet Linien mit der Laenge l: *)
(* Winkel wi: 0 1 2 3 *)
(* *)
(* A <-- | --> *)
(* | V *)
(*------------------------------------------------------------*)
PROCEDURE F(l,wi : INTEGER);
BEGIN
CASE wi OF
0 : di.Draw(screen, screen.rp.x , screen.rp.y-l );
| 1 : di.Draw(screen, screen.rp.x-l , screen.rp.y );
| 2 : di.Draw(screen, screen.rp.x , screen.rp.y+l );
| 3 : di.Draw(screen, screen.rp.x+l , screen.rp.y );
END
END F;
(*------------------------------------------------------------*)
(* Der rekursive Teil *)
(*------------------------------------------------------------*)
PROCEDURE Draw(n,l,wi : INTEGER);
BEGIN
IF n>0 THEN
Draw(n-1,l,wi); F(l,wi); Draw(n-1,l,wt[0,wi]);
F(l,wt[1,wi]); F(l,wi);
Draw(n-1,l,wt[1,wi]); F(l,wt[1,wi]); Draw(n-1,l,wi);
END;
END Draw;
(*------------------------------------------------------------*)
(* Und noch das Hauptprogramm... *)
(*------------------------------------------------------------*)
BEGIN
io.WriteString("\nLaenge : "); retbo:=io.ReadInteger(la);
io.WriteString("\nTiefe : "); retbo:=io.ReadInteger(ti);
io.WriteLn;
InitGraph;
di.Move(screen,la+3,height-3-la);
Draw(ti,la,3); (* 1. Haelfte zeichnen *)
F(la,1); F(la,0); (* Ecke rechts oben *)
Draw(ti,la,1); (* 2. Haelfte zeichnen *)
F(la,3); F(la,2); (* Ecke links unten *)
Mouse.WaitLMB;
Close;
END Wirth.